package com.samphanie.auiu.admin.domain.dto;

import com.samphanie.auiu.admin.domain.vo.ResourceVo;
import com.samphanie.auiu.mbg.model.SysMenu;
import lombok.Builder;
import lombok.Data;
import lombok.With;

import java.util.List;
import java.util.function.Function;

/**
 * @author ZSY
 * @email 1451691457@qq.com
 */
@Data
@With
@Builder
public class MenuDto {

    private Long id;
    private Long parentId;
    private String title;
    private String name;
    private String component;
    private String path;
    private String icon;
    private String redirect;
    private Integer sort;
    private boolean hideInBread;
    private boolean hideInMenu;
    private boolean hideChildren;
    private boolean notCache;
    private Integer type;
    private String link;
    private String remark;
    private List<ResourceVo> operations;

    public static Function<MenuDto, SysMenu> fromMenu = (menu) -> SysMenu.builder()
            .parentId(menu.getParentId())
            .title(menu.getTitle())
            .name(menu.getName())
            .component(menu.getComponent())
            .path(menu.getPath())
            .hidden(menu.isHideInMenu())
            .hideHeader(menu.isHideInBread())
            .hideChildren(menu.isHideChildren())
            .keepAlive(menu.isNotCache())
            .icon(menu.getIcon())
            .redirect(menu.getRedirect())
            .sort(menu.getSort())
            .type(menu.getType())
            .target(menu.getLink())
            .build();

}
